package org.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.web.domain.Info;
import org.web.domain.Sui;
import org.web.domain.User;
import org.web.service.WenZhangService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author:芯古子
 * @Date:2022/4/27 18:30
 **/
@Controller
public class SuiBiController {
    @Resource(name = "wenZhangService")
     private WenZhangService wenZhangService;

    @ResponseBody
    @RequestMapping("suiall")
    public List<Sui> all(){
        List<Sui> all = wenZhangService.all();
        return all;
    }
    @RequestMapping("del")
    public String del(String time){
        wenZhangService.del(time);
        return "redirect:suibi.html";
    }
    @ResponseBody
    @RequestMapping("upa")
    public String upa(HttpServletRequest request){
        String time = request.getParameter("title");
        String thing = request.getParameter("matter");
        wenZhangService.upa(time);
        Sui sui = new Sui();
        sui.setTime(time);
        sui.setThing(thing);
        wenZhangService.up(sui);
        Info info = new Info();
        return "dsss";
        /*为什么用user时报500*/
    }
    @RequestMapping("addsui11")
    public String addsui(HttpServletRequest request){
        String time = request.getParameter("title");
        String thing = request.getParameter("matter");
        Sui sui = new Sui();
        sui.setThing(thing);
        sui.setTime(time);
        wenZhangService.add(sui);
        return "redirect:http://localhost:8089/web2_war_exploded/suibi.html";
    }
}
